import request from '../utils/request';

export const fetchData = () => {
    return request({
        url: './table.json',
        method: 'get'
    });
};

/**
 * 上传图片
 * @param {File} file 图片文件
 * @returns promise
 */
export const uploadImage = (file:any) => {
    let formData = new FormData();
    formData.append("file", file);
    return request({
        url: "/third-party/upload",
        method: "post",
        data: formData
    })
};

// 获取未读消息
export const getUnReadMessageApi = () => {
    return request({
        url: '/message/imChatUserMessage/getUnReadMessage',
    });
};

// 登录
export const loginApi = (param: any) => {
    return request({
        url: '/user/login',
        method: 'post',
        data: param
    });
};

// 注册
export const registerApi = (param: any) => {
    return request({
        url: '/web-user/register',
        method: 'post',
        data: param
    });
};

// 注册
export const passwordApi = (param: any) => {
    return request({
        url: '/web-user/password',
        method: 'put',
        data: param
    });
};


// 添加家政员
export const addHousekeeper = (param: any) => {
    return request({
        url: '/housekeeper',
        method: 'post',
        data: param
    });
};
// 家政员列表
export const getHouseKeeperListApi = (params:any) => {
    return request({
        url: '/housekeeper',
        method: 'get',
        params: params
    });
};
// 修改家政员信息
export const updateHouseKeeperApi = (params:any) => {
    return request({
        url: '/housekeeper',
        method: 'put',
        data: params
    });
};
// 获取家政员信息
export const getHouseKeeperApi = (id:any) => {
    return request({
        url: '/housekeeper/detail/' + id,
        method: 'get'
    });
};
// export const getCompanyAdmin = (companyName:any) => {
//     return request({
//         url: '/company/getByCompanyName',
//         method: 'get',
//         params:{companyName:companyName}
//     });
// };
export const getCompanyAdmin = (id:any) => {
    return request({
        url: '/company/detail/'+id,
        method: 'get',
    });
};

// 服务类型选项
export const getTypeOptions = (params:any) => {
    return request({
        url: '/service-type/options',
        method: 'get',
        params: params
    });
};

// 公司选项选项
export const getCompanyOptions = (params:any) => {
    return request({
        url: '/company/options',
        method: 'get',
        params: params
    });
};

// 添加需求
export const addDemandApi = (param: any) => {
    return request({
        url: '/demand',
        method: 'post',
        data: param
    });
};

// 获取需求信息
export const getDemandApi = (id:any) => {
    return request({
        url: '/demand/detail/' + id,
        method: 'get'
    });
};

// 获取匹配信息
export const getMatchListApi = (id:any) => {
    return request({
        url: '/demand/match-list/' + id,
        method: 'get'
    });
};

// 需求列表
export const getDemandListApi = (params:any) => {
    return request({
        url: '/demand',
        method: 'get',
        params: params
    });
};

// 订单列表
export const getOrderFormListApi = (params:any) => {
    return request({
        url: '/order/order-form',
        method: 'get',
        params: params
    });
};

// 获取订单详情
export const getOrderFormApi = (id:any) => {
    return request({
        url: '/order/order-form/detail/' + id,
        method: 'get'
    });
};

// 公司接单
export const acceptOrderFormApi = (id:any) => {
    return request({
        url: '/order/order-form/accept/' + id,
        method: 'put'
    });
};

// 用户支付
export const payOrderFormApi = (id:any) => {
    return request({
        url: '/order/order-form/pay/' + id,
        method: 'put'
    });
};

// 取消
export const cancelOrderFormApi = (id:any) => {
    return request({
        url: '/order/order-form/cancel/' + id,
        method: 'put'
    });
};

// 开始
export const startOrderFormApi = (id:any) => {
    return request({
        url: '/order/order-form/start/' + id,
        method: 'put'
    });
};

// 结束
export const endOrderFormApi = (param:any) => {
    return request({
        url: '/order/order-form/end/',
        method: 'put',
        data: param
    });
};

// 确认
export const confirmOrderFormApi = (param:any) => {
    return request({
        url: '/order/order-form/confirm/',
        method: 'put',
        data: param
    });
};

// 从需求创建订单
export const createOrderFromDemandApi = (param:any) => {
    return request({
        url: '/order/order-form/demand-to-order/',
        method: 'post',
        data: param
    });
};

// 从家政员创建订单
export const createOrderFromHousekeeperApi = (param:any) => {
    return request({
        url: '/order/order-form/housekeeper-to-order/',
        method: 'post',
        data: param
    });
};

// 获取统计数据
export const getDataApi = () => {
    return request({
        url: '/data/',
        method: 'get'
    });
};

// 获取订单统计数据
export const getOrderDataApi = () => {
    return request({
        url: '/order/order-form/data',
        method: 'get'
    });
};

// 重新匹配需求
export const flushDemandApi = (id: any) => {
    return request({
        url: '/demand/flush/' + id,
        method: 'put'
    });
};

// 订单列表(默认添加身份条件)
export const getOrderListApi = (param: any) => {
    return request({
        url: '/order',
        method: 'get',
        params: param
    });
};

// 订单列表(快递员使用)
export const getOrderListByCourierApi = (param: any) => {
    return request({
        url: '/order/listByCourier',
        method: 'get',
        params: param
    });
};

// 订单列表(不添加身份条件)
export const getReceiveOrderListApi = (param: any) => {
    return request({
        url: '/order/listReceive',
        method: 'get',
        params: param
    });
};

// 订单详细
export const getOrderDetailApi = (param: any) => {
    return request({
        url: '/order/detail',
        method: 'get',
        params: param
    });
};
// 操作日志
export const getLogListApi = (param: any) => {
    return request({
        url: '/express/sys-log',
        method: 'get',
        params: param
    });
};

// 更新订单
export const updateOrderApi = (param: any) => {
    return request({
        url: '/order',
        method: 'put',
        data: param
    });
};

// 操作订单
export const operateOrderApi = (param: any) => {
    return request({
        url: '/order/operate',
        method: 'put',
        data: param
    });
};

// 订单批量操作
export const batchOperateOrderApi = (param: any) => {
    return request({
        url: '/order/batch-operate/' + param,
        method: 'put',
    });
};

// 用户拒收订单
export const refuseOrderApi = (param: any) => {
    return request({
        url: '/order/refuse/' + param,
        method: 'put',
    });
};

//用户管理
// 示例列表
export const getWebUserListApi = (param: any) => {
    return request({
        url: '/web-user',
        method: 'get',
        params: param
    });
};


// 示例新增
export const addWebUserApi = (param: any) => {
    return request({
        url: '/web-user',
        method: 'post',
        data: param
    });
};

// 示例修改
export const updateWebUserApi = (param: any) => {
    return request({
        url: '/web-user',
        method: 'put',
        data: param
    });
};

// 示例删除
export const deleteWebUserApi = (id: number) => {
    return request({
        url: '/web-user/' + id,
        method: 'delete'
    });
};

// 快递类型列表
export const getTypeListApi = (param: any) => {
    return request({
        url: '/type',
        method: 'get',
        params: param
    });
};


// 快递类型新增
export const addTypeApi = (param: any) => {
    return request({
        url: '/type',
        method: 'post',
        data: param
    });
};

// 快递类型修改
export const updateTypeApi = (param: any) => {
    return request({
        url: '/type',
        method: 'put',
        data: param
    });
};

// 快递类型删除
export const deleteTypeApi = (id: number) => {
    return request({
        url: '/type/' + id,
        method: 'delete'
    })
};

// 网点列表
export const getOutletListApi = (param: any) => {
    return request({
        url: '/outlet',
        method: 'get',
        params: param
    });
};

// 网点新增
export const addOutletApi = (param: any) => {
    return request({
        url: '/outlet',
        method: 'post',
        data: param
    });
};

// 网点修改
export const updateOutletApi = (param: any) => {
    return request({
        url: '/outlet',
        method: 'put',
        data: param
    });
};

// 网点删除
export const deleteOutletApi = (id: number) => {
    return request({
        url: '/outlet/' + id,
        method: 'delete'
    });
};

// 地址簿列表
export const getAddressBookListApi = (param: any) => {
    return request({
        url: '/address-book',
        method: 'get',
        params: param
    });
};


// 地址簿新增
export const addAddressBookApi = (param: any) => {
    return request({
        url: '/address-book',
        method: 'post',
        data: param
    });
};

// 地址簿修改
export const updateAddressBookApi = (param: any) => {
    return request({
        url: '/address-book',
        method: 'put',
        data: param
    });
};

// 地址簿列表
export const getCompanyListApi = (param: any) => {
    return request({
        url: '/company',
        method: 'get',
        params: param
    });
};


// 地址簿新增
export const addCompanyApi = (param: any) => {
    return request({
        url: '/company',
        method: 'post',
        data: param
    });
};

// 地址簿修改
export const updateCompanyApi = (param: any) => {
    return request({
        url: '/company',
        method: 'put',
        data: param
    });
};



// 服务类型列表
export const getServiceTypeListApi = (param: any) => {
    return request({
        url: '/service-type',
        method: 'get',
        params: param
    });
};


// 服务类型新增
export const addServiceTypeApi = (param: any) => {
    return request({
        url: '/service-type',
        method: 'post',
        data: param
    });
};

// 服务类型修改
export const updateServiceTypeApi = (param: any) => {
    return request({
        url: '/service-type',
        method: 'put',
        data: param
    });
};

// 地址簿删除
export const deleteAddressBookApi = (id: number) => {
    return request({
        url: '/address-book/' + id,
        method: 'delete'
    });
};

// 资源列表
export const getResourceListApi = () => {
    return request({
        url: '/resource',
        method: 'get',
    });
};

// 根据角色资源列表
export const getResourceListByRoleApi = (roleId: string) => {
    return request({
        url: '/resource/' + roleId,
        method: 'get',
    });
};

// 更新角色资源
export const updateRoleResource = (param:any) => {
    return request({
        url: '/resource/',
        method: 'post',
        data: param
    });
};

// 数据大屏
export const getDashboardApi = (param: any) => {
    return request({
        url: '/order/dashboard',
        method: 'get',
        params: param
    });
};

// 地址簿列表
export const getUserListApi = (param: any) => {
    return request({
        url: '/user/list',
        method: 'get',
        params: param
    });
};


// 地址簿新增
export const addUserApi = (param: any) => {
    return request({
        url: '/user',
        method: 'post',
        data: param
    });
};

// 地址簿修改
export const updateUserApi = (param: any) => {
    return request({
        url: '/user',
        method: 'put',
        data: param
    });
};
